<template>
    <el-dialog
    :title="dialogTitle"
    :visible.sync="diagnosisName"
    width="55%"
    class="class_c"
    center>
    <div>
      <template>
        <div>
          <div class="container">
            <div>
              <el-form :model="formInlineDisease" ref="formInlineDisease">

                <el-row type="flex">
                  <el-col :span="12">
                    <el-form-item label="疾病编码">
                      <el-input v-model="formInlineDisease.diseCode" placeholder="请输入疾病编码"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12" :offset="4">
                    <el-form-item label="疾病名称">
                      <el-input v-model="formInlineDisease.diseName" placeholder="请输入疾病名称"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row type="flex">
                  <el-col :span="24" style="text-align: center">
                    <div>
                      <el-button type="primary" @click="queryDiseaseList">
                        查询
                      </el-button>
                    </div>
                  </el-col>
                </el-row>
              </el-form>
            </div>
            <template>
              <div>
                <el-divider></el-divider>
              </div>
            </template>
            <el-table
              :data="diseaseList"
              class="table"
              ref="multipleTable"
              header-cell-class-name="table-header"
              style="margin-top: 30px"
            >
              <el-table-column prop="diseCode" label="疾病编码" align="center"></el-table-column>
              <el-table-column prop="diseName" label="疾病名称" align="center"></el-table-column>
              <el-table-column label="操作栏" align="center" show-overflow-tooltip>
                <template slot-scope="scope">
                  <el-button type="text" @click="selectDetails(scope.row)">选定</el-button>
                </template>
              </el-table-column>
            </el-table>
            <div class="pagination">
              <el-pagination :current-page="pagination.currentPage" :page-size="pagination.rowsNumber"
                            :total="pagination.totalPage" background layout="prev, pager, next,total,jumper"
                              @current-change="queryFun">
              </el-pagination>
            </div>

          </div>
        </div>

      </template>
    </div>
  </el-dialog>
</template>
 
<script>
import * as api from '@/api/baseDate'
export default {
  name: "DiagnosisComponent",
  props: {
    dialogTitle: {
      type: String,
      default: "疾病选择",
    }
  },
  data() {
    return {
    diagnosisName: false,
    formInlineDisease:{},
    //疾病诊断
    diseaseList:[],
      //疾病分页
    pagination: {
        currentPage: 1, // 当前页
        rowsNumber: 5, // 每页条数
        totalPage: 0 // 总条数
    },
    };
  },
  methods: {
       //疾病分页
       queryFun(pageNum){ // 改变当前页事件
        this.pagination.currentPage=pageNum
        this.queryDiseaseList();
       },
       //查询疾病接口
       queryDiseaseList(){
        api.queryDiseaseLists({
          "diseCode":this.formInlineDisease.diseCode,
          "diseName":this.formInlineDisease.diseName,
          "pageNum":this.pagination.currentPage,
          "pageSize":this.pagination.rowsNumber,
        }
        ).then(res => {
          if(res){
             if(res.data.resultCode){
                 if(res.data.resultCode != '0000'){
                        // 返回失败
                        this.$message.error(res.data.resultMsg);
                  }else{
                        // 返回成功
                        this.diseaseList = res.data.list
                        this.pagination.totalPage = res.data.total;
                    }
                }
              }else{
                  this.$message.error('系统异常');
              }
        })
      },
       //疾病选定
       selectDetails(e){
        this.$emit('children',e)
      },
  
  }
};
</script>
